Problem Note 50949: Using the position rather than the name of a variable in a GROUP BY clause might result in an error
An error might occur when you run an SQL procedure query when the following conditions exist:
- An SQL view includes the creation of a new variable as a result of a summary function.
- The view is used in a subsequent query where it is joined to another table using an outer join and the new variable is used in the GROUP BY clause.
- The variable position in the SELECT clause rather than the variable name is used in the GROUP BY clause.
The error might look similar to the following:
ERROR: GROUP BY clause contains a summary function, which is not allowed.
ERROR: Summary functions are restricted to the SELECT and HAVING clauses only.
Submitting a query similar to the following might result in the above error:
proc sql;
create view v2 as
select
x, y, max(z) as mz
from t2
group by x, y;
quit;
proc sql;
create table results as
select t1.x, sum(t1.y) as sy, v2.mz
from t1 left join v2
on t1.x=v2.x
group by 3;
quit;
The only workaround is to use the variable name rather than its position in the GROUP BY clause.
Operating System and Release Information
SAS System | Base SAS | z/OS | 9.3 TS1M2 | 9.4 TS1M1 |
Z64 | 9.3 TS1M2 | 9.4 TS1M1 |
Microsoft® Windows® for x64 | 9.3 TS1M2 | 9.4 TS1M1 |
Microsoft Windows 8 Enterprise 32-bit | 9.3 TS1M2 | 9.4 TS1M1 |
Microsoft Windows 8 Enterprise x64 | 9.3 TS1M2 | 9.4 TS1M1 |
Microsoft Windows 8 Pro 32-bit | 9.3 TS1M2 | 9.4 TS1M1 |
Microsoft Windows 8 Pro x64 | 9.3 TS1M2 | 9.4 TS1M1 |
Microsoft Windows Server 2003 Datacenter Edition | 9.3 TS1M2 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.3 TS1M2 | |
Microsoft Windows Server 2003 Standard Edition | 9.3 TS1M2 | |
Microsoft Windows Server 2003 for x64 | 9.3 TS1M2 | |
Microsoft Windows Server 2008 | 9.3 TS1M2 | |
Microsoft Windows Server 2008 R2 | 9.3 TS1M2 | 9.4 TS1M1 |
Microsoft Windows Server 2008 for x64 | 9.3 TS1M2 | 9.4 TS1M1 |
Microsoft Windows Server 2012 Datacenter | 9.3 TS1M2 | 9.4 TS1M1 |
Microsoft Windows Server 2012 Std | 9.3 TS1M2 | 9.4 TS1M1 |
Microsoft Windows XP Professional | 9.3 TS1M2 | |
Windows 7 Enterprise 32 bit | 9.3 TS1M2 | |
Windows 7 Enterprise x64 | 9.3 TS1M2 | 9.4 TS1M1 |
Windows 7 Home Premium 32 bit | 9.3 TS1M2 | |
Windows 7 Home Premium x64 | 9.3 TS1M2 | |
Windows 7 Professional 32 bit | 9.3 TS1M2 | |
Windows 7 Professional x64 | 9.3 TS1M2 | 9.4 TS1M1 |
Windows 7 Ultimate 32 bit | 9.3 TS1M2 | |
Windows 7 Ultimate x64 | 9.3 TS1M2 | |
Windows Vista | 9.3 TS1M2 | |
Windows Vista for x64 | 9.3 TS1M2 | |
64-bit Enabled AIX | 9.3 TS1M2 | 9.4 TS1M1 |
64-bit Enabled HP-UX | 9.3 TS1M2 | 9.4 TS1M1 |
64-bit Enabled Solaris | 9.3 TS1M2 | 9.4 TS1M1 |
HP-UX IPF | 9.3 TS1M2 | 9.4 TS1M1 |
Linux | 9.3 TS1M2 | 9.4 TS1M1 |
Linux for x64 | 9.3 TS1M2 | 9.4 TS1M1 |
Solaris for x64 | 9.3 TS1M2 | 9.4 TS1M1 |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Type: | Problem Note |
Priority: | high |
Date Modified: | 2013-10-31 09:10:47 |
Date Created: | 2013-09-03 15:16:09 |